<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">	
<link rel="shortcut icon" type="image/x-icon" href="{{URL::asset('handan/images/logo-icon.png')}}" />
<title>资料设置</title>
<link rel="stylesheet" href="{{URL::asset('mobile/css/public.css') }}"/>
<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
<link rel="stylesheet" href="{{URL::asset('mobile/js/city/jquery-weui.min.css')}}">
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script src="{{URL::asset('mobile/js/public.js') }}"></script>
<script src="{{URL::asset('mobile/js/city/city-picker.min.js') }}"></script>
<script src="{{URL::asset('mobile/js/city/jquery-weui.min.js') }}"></script>

</head>
<body>
	@include('mobile.msg')
    <div class="page">
		<div class="content">
		  <div class="list-block">
		    <ul>
		      <!-- Text inputs -->
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-name"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称</div>
		            <div class="item-input">
		              <input type="text" placeholder="Your name" maxlength="6" value="{{$baseinfo->username}}" id="username" disabled="disabled">
		            </div>
		          </div>
		        </div>
		      </li>
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-gender"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别</div>
		            <div class="item-input">
		              <select id="sex">
		              	
		                <option value="2" @if($baseinfo->sex == 2) selected @endif>女</option>
		                <option value="1" @if($baseinfo->sex != 2) selected @endif>男</option>
		              </select>
		            </div>
		          </div>
		        </div>
		      </li>
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-calendar"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">生&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日</div>
		            <div class="item-input">
		              <input type="text" id="my-input" @if($baseinfo->birthday) value="{{date('Y-m-d',$baseinfo->birthday)}}" @else value="{{date('Y-m-d',time())}}" @endif/>
		            </div>
		          </div>
		        </div>
		      </li>
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-email"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区</div>
		            <div class="item-input">
		              <input type='text' id='city-picker' placeholder="请选择地区" value="@if($authinfo){{$authinfo->province}} {{$authinfo->city}} {{$authinfo->country}}@endif"/>
		            </div>
		          </div>
		        </div>
		      </li>
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-password"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">经济商</div>
		            <div class="item-input">
		              <input type="text" placeholder="经济商" value="{{$baseinfo->server_name}}" id="server_name">
		            </div>
		          </div>
		        </div>
		      </li>
		      <li>
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-email"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱</div>
		            <div class="item-input">
		              <input type="email" placeholder="E-mail" value="{{$baseinfo->email}}" id="email">
		            </div>
		          </div>
		        </div>
		      </li>
		      <!-- Date -->      
		      <!-- Switch (Checkbox) -->
		      <li class="align-top">
		        <div class="item-content">
		          <div class="item-media"><i class="icon icon-form-comment"></i></div>
		          <div class="item-inner">
		            <div class="item-title label">个人简介</div>
		            <div class="item-input">
		              <textarea placeholder="个人简介" id="IntroductionValue">{{$baseinfo->introduction}}</textarea>
		            </div>
		          </div>
		        </div>
		      </li>
		    </ul>
		  </div>
		  <div class="content-block">
		    <div class="row">
		      <!--<div class="col-50"><a href="#" class="button button-big button-fill button-danger">取消</a></div>-->
		      <div class="col-100" id="btnSaveUD"><a href="#" class="button button-big button-fill button-success">提交</a></div>
		    </div>
		  </div>
		</div>
	</div>
</div>
</body>
<style>
.list-block .item-content{
	margin-left: 0.75rem;
	padding-left: 0rem;
}
.list-block{
	margin: 0;
}
.list-block .item-media+.item-inner{
	margin-left: 0;
}
.content-block{
	/*padding: 0;
	margin: 0;*/
	position:relative;
	top:3rem;
	width: 100%;
}
.button-success.button-fill{
	background: #3290d2;
}
.list-block .item-title{
	font-size: 0.7rem;
}
.list-block .item-title.label{
	width: 30%;
}
.list-block input[type=text], .list-block input[type=password], .list-block input[type=email], .list-block input[type=tel], .list-block input[type=url], .list-block input[type=date], .list-block input[type=datetime-local], .list-block input[type=time], .list-block input[type=number], .list-block input[type=search], .list-block select, .list-block textarea{
	font-size: 0.7rem;
}
</style>
<script src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script>
//发送ajax	
var dobaseinfo = '{{url("dobaseinfo")}}';
//生日日期	
$(function() {
var dataArr_one = '',
	dataArr_two = '',
	dataArr_thr = '';
$("#btnSaveUD").click(function() {
	var username = $.trim($("#username").val()); //用户名
    var sex = $("#sex").attr('value');  //性别
    var birthday = $("#my-input").val();  //生日
    var email = $.trim($("#email").val()); //邮箱
    var introduction = $.trim($("#IntroductionValue").val()); //个人简介
    var server_name  = $.trim($("#server_name").val());   //外汇平台
    var city_picker  = $.trim($("#city-picker").val());   //地区
    var regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
	if(email === '' || !(regex.test(email))){
       msg('请输入合法的邮箱地址!');
       return;
	}
    if(sex=='' || birthday=='' || email=='' || server_name=='' || city_picker=='') {
        msg('请将资料完善');
        return;
    }
    $.ajax({
            type: "POST",
            data: {
            	username: username,
                birthday: birthday,
                server_name: server_name,
                email: email,
                sex: sex,
                introduction: introduction,
                province: dataArr_one,
                city: dataArr_two,
                country:dataArr_thr
            },
            url: dobaseinfo,
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            dataType:'json',
            success:function(data) {
                if(data.status == 0) {
                    msg("设置成功！");
                }else if(data.status == 2){ //申请体验账户成功，开始倒计时
                	msg("申请成功");
                }else{
                    msg("您还未登录，请先登录");
                }
            }
    })
});
	var posturl = "{{ url('/checkname') }}";
	'use strict';
	var date = new Date();
	var hmd = zeroPadding(date.getFullYear())+'-'+zeroPadding(date.getMonth()+1)+'-'+zeroPadding(date.getDate());
	$(document).on("pageInit", function() {
	    $("#my-input").calendar({
		  maxDate:[hmd],
	      onChange: function(p, v, d) {
	      }
	    });
	  });
	$.init();

	$("#city-picker").cityPicker({
        title: "选择省市区/县",
        onChange: function (picker, values, displayValues) {
        	dataArr_one = displayValues[0];
        	dataArr_two = displayValues[1];
        	dataArr_thr = displayValues[2];
        }
    });
});
//创建补0函数
function zeroPadding(s) {
    return s < 10 ? '0' + s: s;
}
</script>
</html>